﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nage.Algorithms.Solution;

namespace Nage.Algorithms.Population
{
    /// <summary>
    /// Population interface. When implemented, it is 
    /// </summary>
    /// <typeparam name="TSol">Type of the solution</typeparam>
    public interface IPopulation<TSol> : ICollection<TSol>
        where TSol : ISolution
    {
        /// <summary>
        /// Collection containing evaluator for each solution in population
        /// </summary>
        ICollection<ISolutionEvaluator<TSol>> EvaluationList { get; }

        /// <summary>
        /// Boolean value that indicates whether the population contains solutions or not.
        /// </summary>
        Boolean IsEmpty { get; }
        
        /// <summary>
        /// Retrieves the solution evaluator for particular solution in the population.
        /// If population does not contain given solution, null value should be returned respectively
        /// </summary>
        /// <param name="solution">solution for which the evaluator is searched</param>
        /// <returns>solution evaluator</returns>
        ISolutionEvaluator<TSol> GetEvaluation(TSol solution);

        /// <summary>
        /// Sets the solution evaluator for particular solution in the population
        /// </summary>
        /// <param name="solution">solution</param>
        /// <param name="evaluation">evaluator</param>
        void SetEvaluation(TSol solution, ISolutionEvaluator<TSol> evaluation);

        /// <summary>
        /// Sets the same solution evaluator for all of the solutions in the population
        /// </summary>
        /// <param name="evaluation">evaluator</param>
        void SetAllEvaluations(ISolutionEvaluator<TSol> evaluation);

        /// <summary>
        /// Provides a dictionary representation for the population
        /// mapping solutions into evaluators
        /// </summary>
        /// <returns>dictionary where keys are solutions and values are evaluators</returns>
        IDictionary<TSol, ISolutionEvaluator<TSol>> AsDictionary();
    }
}
